<?php
/*
*All rights reserved: Json.
*Links:http://www.liyaoquan.cn.
*Links:http://imarkchina.cn.
*Links:http://www.imarkchina.cn.
*/

/**
 * 博客前台显示日志/专题控制器，负责，业务流程判断
 */
Class ShowAction extends Action{

	/**
	 * 显示模板
	 * @return [type] [description]
	 */
	Public function index(){
		$id = G('get.id');
		$page = loadfile(C('page.id'));
		if (in_array_case($id, $page)) {
			$this->page();
			exit();
		} else {
			$this->post();
			exit();
		}
	}

	/**
	 * 显示日志内容
	 * @return [type] [description]
	 */
	Public function post(){
		$id = G('get.id');
		C('TPLCACHENAME', 'post-'.$id);
		C('TPLCACHEING', C('CHECKCACHEING'));
		if (!$this->isCache()) {
			$M = M('show')->showPost($id);
			if ($M) {
				$this->assign('check', $M['check']);
				$this->assign('file', $M['file']);
				$this->assign('lastp', $M['getlast']);
				$this->assign('nextp', $M['getnext']);
				$this->assign('id', $id);
			} else {
				$this->error('Shit, 没找日志？');
			}
		}
		M('Show')->hits($id);
		$this->display();
	}

	/**
	 * 显示专题内容
	 * @return [type] [description]
	 */
	Public function page(){
		$id = G('get.id');
		C('TPLCACHENAME', 'page-'.$id);
		C('TPLCACHEING', C('CHECKCACHEING'));
		if (!$this->isCache('page-'.$id)) {
			$M = M('show')->showPage($id);
			if ($M) {
				$this->assign('file', $M);
				$this->assign('id', $id);
			} else{
				$this->error('Shit, 没找专题？');
			}
		}
		M('Show')->hits($id);
		$this->display();
	}
}